package com.zsc.newbuds.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author D
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    /**
     * 实现无业务逻辑跳转
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
    }

    /**
     * 登录拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginConfig loginConfig = new LoginConfig();
        InterceptorRegistration loginRegistry = registry.addInterceptor(loginConfig);

        //拦截路径
        loginRegistry.addPathPatterns("/user/**");
        loginRegistry.addPathPatterns("/shop");

        //排除资源请求
        loginRegistry.excludePathPatterns("/asserts/**");
    }

}
